package com.ruoyi.lock.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.lock.domain.ALogs;
import com.ruoyi.lock.mapper.ALogsMapper;
import com.ruoyi.lock.service.IALogsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 开锁日志表Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-08-05
 */
@Service
public class ALogsServiceImpl implements IALogsService 
{
    @Autowired
    private ALogsMapper aLogsMapper;


    /**
     * 查询开锁日志表
     * 
     * @param id 开锁日志表主键
     * @return 开锁日志表
     */
    @Override
    public ALogs selectALogsById(Long id)
    {
        return aLogsMapper.selectALogsById(id);
    }

    /**
     * 查询开锁日志表列表
     * 
     * @param aLogs 开锁日志表
     * @return 开锁日志表
     */
    @Override
    public List<ALogs> selectALogsList(ALogs aLogs)
    {
        return aLogsMapper.selectALogsList(aLogs);
    }

    /** 开锁方式数量 */
    @Override
    public List<JSONObject> selectCountLogsLock(ALogs aLogs) {
        return aLogsMapper.selectCountLogsLock(aLogs);
    }

    @Override
    public List<ALogs> selectALogsList1(ALogs aLogs)
    {
        //根据unicode查询用户,房间id查询锁
//        ATenant aTenant = aTenantMapper.selectATenantByuniCode(aLogs.getUniCode());
//        if(aTenant != null){
//            ASmartlocks aSmartlocks = aSmartlocksMapper.selectASmartlocksByRoomId(Long.valueOf(aTenant.getRoomId()));
//            aLogs.setMac(aSmartlocks.getMac());
//        }
        return aLogsMapper.selectALogsList1(aLogs);
    }

    /**
     * 新增开锁日志表
     * 
     * @param aLogs 开锁日志表
     * @return 结果
     */
    @Override
    public int insertALogs(ALogs aLogs)
    {
        aLogs.setCreateTime(DateUtils.getNowDate());

        aLogs.setLockTime(DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD_HH_MM_SS));
        return aLogsMapper.insertALogs(aLogs);
    }

    /**
     * 修改开锁日志表
     * 
     * @param aLogs 开锁日志表
     * @return 结果
     */
    @Override
    public int updateALogs(ALogs aLogs)
    {
        aLogs.setUpdateTime(DateUtils.getNowDate());
        return aLogsMapper.updateALogs(aLogs);
    }

    /**
     * 批量删除开锁日志表
     * 
     * @param ids 需要删除的开锁日志表主键
     * @return 结果
     */
    @Override
    public int deleteALogsByIds(Long[] ids)
    {
        return aLogsMapper.deleteALogsByIds(ids);
    }

    /**
     * 删除开锁日志表信息
     * 
     * @param id 开锁日志表主键
     * @return 结果
     */
    @Override
    public int deleteALogsById(Long id)
    {
        return aLogsMapper.deleteALogsById(id);
    }

    @Override
    public List<ALogs> devicesNoLockActivity24h(ALogs aLogs)
    {
        return aLogsMapper.devicesNoLockActivity24h(aLogs);
    }

}
